package com.SDR.Dao.Impl;

import com.SDR.Dao.RedisDao;
import com.SDR.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
 * Created by Yoey on 2017/6/26.
 */
@Repository("userRedisDaoImpl")
public class UserRedisDaoImpl implements RedisDao<User> {
    @Autowired
    RedisTemplate<String,Serializable> redisTemplate;

    @Override
    public User getFromRedis(String param1) {
        return (User)redisTemplate.opsForValue().get(param1);
    }

    @Override
    public void setIntoRedis(String param1, User param2) {
        param1=param2.getName();
        redisTemplate.opsForValue().set(param1,param2);
    }
}
